package com.hxzy.servlet.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author nick
 */
@WebServlet("/session3")
public class MySession3Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        System.out.println("session3:  移除session作用域的数据" + session);
        //从session作用域中移除userName
        session.removeAttribute("userName");

        //直接使session失效，相当于session的MaxInactiveInternal立刻到期
        session.invalidate();//退出登录就可以用这个方法实现；

    }
}
